﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/2/2009
 * Time: 11:35 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of WorkersCompensationForm.
	/// </summary>
	public partial class WorkersCompensationForm : BaseForm
	{
		public WorkersCompensationForm() : this(new WorkersCompensation())
		{
			
		}
		
		public WorkersCompensationForm(WorkersCompensation c)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = c;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			WorkersCompensation c = Model as WorkersCompensation;
			textBoxCode.Text = c.Code;
			textBoxDescription.Text = c.Description;
			textBoxRate.Text = c.Rate.ToString("0.00");
			dateTimePickerStartUsing.Value = c.StartUsingOn;
			checkBoxInactive.Checked = c.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			WorkersCompensation c = Model as WorkersCompensation;
			c.Code = textBoxCode.Text;
			c.Description = textBoxDescription.Text;
			c.Rate = Util.ConvertUtility.ToDouble(textBoxRate.Text);
			c.StartUsingOn = dateTimePickerStartUsing.Value;
			c.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdateWorkersCompensation(c);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
